package pub.tbc.toolkit.http;

/**
 *
 * @author tbc tianbencai@e-eduspace.com
 * @version 1.0 {2015年11月17日 下午3:39:53}
 */
public class HttpResponseWrapperUtil {

	HttpResponseWrapper responseWrapper = new HttpResponseWrapper();

	private void set(String code, String msg, String exception, String response) {
		if (null == code || "".equals(code)) {
			code = "500";
		}
		if (null == msg) {
			msg = "";
		}
		if (null == exception) {
			msg = "";
		}
		if (null == response) {
			msg = "";
		}
		responseWrapper.setCode(code);
		responseWrapper.setMsg(msg);
		responseWrapper.setException(exception);
		responseWrapper.setResponse(response);
	}

	public void exception(String code, String msg, String exception) {
		set(code, msg, exception, null);
	}

	public void exception(String msg, String exception) {
		exception("500", msg, exception);
	}

	public void exception(String exception) {
		exception("", exception);
	}

	public void ok(String msg, String response) {
		set("200", msg, "", response);
	}

	public void ok(String response) {
		set("200", "ok", "", response);
	}

	public void noOk(String code, String msg) {
		if (null == code || "".equals(code)) {
			code = "400";
		}
		set(code, msg, "", null);
	}

	public HttpResponseWrapper getHttpResponseWrapper() {
		return responseWrapper;
	}

}
